package com.ly.jdk8.time;
import java.text.ParseException;
import	java.util.ArrayList;
import	java.util.List;
import	java.util.Date;
import java.util.concurrent.*;

import java.text.SimpleDateFormat;

/**
 * @Classname SimpleDateFormatUnSafe
 * @Description TODO
 * @Date 2020/9/29 18:00
 * @Author 冷心影翼
 */
public class SimpleDateFormatUnSafe {

	public static void main(String[] args) throws InterruptedException, ExecutionException, TimeoutException, ParseException {
		SimpleDateFormat simpleDateFormat  = new SimpleDateFormat("yyyy-MM-dd");
		ExecutorService executor = new ThreadPoolExecutor(3,5,
			20,TimeUnit.SECONDS,new LinkedBlockingQueue<>(3),Executors.defaultThreadFactory(), new ThreadPoolExecutor.DiscardPolicy());
		System.out.println(simpleDateFormat.parse("2018-06-17"));
		Callable<Date> task = () -> simpleDateFormat.parse("2018-06-17");

		List<Future<Date>> list = new ArrayList<> ();

		try{
			for (int i = 0; i < 10; i++) {
				list.add(executor.submit(task));
			}

			for (Future<Date> future : list) {
				System.out.println(future.get());
			}
		}catch(Exception e){
			System.out.println(e);
		}finally {
			executor.shutdown();
		}


	}
}
